package com.glory.cqaospda.viewmodel

import com.glory.cqaospda.model.TaskRepository
import com.glory.mvvmnet.base.BaseViewModel
import com.glory.mvvmnet.entity.CallObserveBean
import com.google.gson.JsonObject

class StateSwitchingModel : BaseViewModel() {

    private val repository by lazy { TaskRepository() }

    fun defaultGetBaseConfig(type:String){

        val map = JsonObject()
        map.addProperty("GroupID", type)

        launchOnlyResult({
            val baseConfigBean =
                repository.defaultGetBaseConfig(map,"EMS_GetBaseConfig")
            defUI.callObserve.value = CallObserveBean(1,baseConfigBean)
        })
    }

    fun defaultGetEqpStatus(eqpID: String) {
        val map = JsonObject()
        map.addProperty("EquipmentName", eqpID)
        launchOnlyResult({
            val eqpStatusBean =
                repository.defaultGetEqpStatus(map,"EMS_GetEqpStatus")
            defUI.callObserve.value = CallObserveBean(2,eqpStatusBean)
        })
    }

    fun defaultStatusChange(map: JsonObject,messageName:String) {
        launchOnlyResult({
            repository.defaultStatusChange(map,messageName)
            defUI.callObserve.value = CallObserveBean(3)
        })
    }

}